<?php

namespace app\index\controller;
use think\facade\Hook;
use think\container;
use think\Db;

class System
{

    //protected $instance = null;

    public function __construct()
    {
        //$this->instance = new self();

        $process = new \swoole\process();

        $process->on('request', function($serv,$fd) {
           //var_dump($serv->);
        });

    }

    public function test()
    {
        /**TP容器的使用**/
        //$container = new container();
        //$container->bindTo('Mail', function() {
        //    return new Mail();
        //});
        //
        //var_dump($container);die;
        //
        //echo $container->make('Mail')->send();


        $this->on('start', function($mail,$fd) {
            //echo "14564";
			echo $fd.PHP_EOL;
			var_dump($mail->send());die;
        });

        //var_dump($res);die;
    }

    // 外部调用方法
    public function on($method, $callback)
    {
        return call_user_func([new self(),$method],$callback);
    }
	

    public function start($callback)
    {
        //return func_get_args();
		$mail = new Mail();
        return call_user_func($callback,$mail,12);
    }

}
